function diff=avidiff( src, filename )
% diff=avidiff( src ) - crerates new movie,
% wchich frmes are
% luminance differenves between frames of source movie.
% thif hass one frame less than source movie.

if exist( 'filename' ) == 1
	diffname = filename;
else
	diffname = 'tmp.avi';
end

srcframes = size( src, 2 )
diff = [];

for i = 1:( srcframes - 1 )
	% progress indicator
	disp( sprintf( '%d/%d', i, srcframes -1 ) );

	% get src frames
	bwframe1 = lumin( src(i).cdata );
	bwframe2 = lumin( src(i+1).cdata );
	
	% actual conversion (note: back to int8 type)
	diffcdata = abs( double( bwframe2 ) - double( bwframe1 ) );
	
	%prepare frame to movie
	frame.cdata = diffcdata;
	frame.colormap = src(i).colormap; % copy from source
	
	% add
	diff = [ diff , frame ];
end

